package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.vo.OrderSettingVo;
import com.itheima.health.pojo.entity.OrderSetting;
import com.itheima.health.pojo.result.Result;
import com.itheima.health.service.OrdersettingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RequestMapping("/ordersetting")
@RestController
public class OrdersettingController {
    @Autowired
    private OrdersettingService orderSettingService;

    @GetMapping("/getOrderSettingByMonth")
    public Result getOrderSettingByMonth(@RequestParam("year") Integer yeal,@RequestParam("month") Integer month) {
        List<OrderSettingVo> setting = orderSettingService.getOrderSettingByMonth(yeal, month);
        return new Result(true, MessageConst.GET_ORDERSETTING_SUCCESS,setting);
    }

    @PostMapping("/editNumberByDate")
    public Result editOrderSetting(@RequestBody OrderSetting orderSetting){
        orderSettingService.addOrderSetting(orderSetting);
        return new Result(true, MessageConst.ORDERSETTING_SUCCESS);
    }
}
